12. Menu Systems and Input Axis II

07 L Menu Systems And Input Axis Part2

If you're an Oculus Rift user, reviewer David Fierstein has devised a way to use the Rift thumbstick for swiping instead of the touchpad on the Vive. Here are the three changes you would need to make to the code:

1) Add a boolean to the class, which is false unless an Oculus device is being used.

    private bool oculus;

2) Add the following to the Start method, which sets the bool oculus to true if Oculus Rift is detected (the word ‘Oculus’ is found in the model name)

        if (UnityEngine.XR.XRDevice.model.Contains("Oculus")) 
        {
            oculus = true;
        } else
        {
            oculus = false;
        }

3) in the Update method, under where it might say:

touchCurrent = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;

Replace this code:

distance = touchCurrent - touchLast; 
touchLast = touchCurrent; 
swipeSum += distance;

With this code:

                if (oculus)
                {
                    swipeSum = touchCurrent;
                } else 
                {
                    distance = touchCurrent - touchLast;
                    touchLast = touchCurrent;
                    swipeSum += distance;
                }

The images below show the changes in context in HandInteraction.cs

Project Preview:
Pick up objects Four or more menu items exist.